﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAL;

/// <summary>
/// Summary description for CateRouteBO
/// </summary>
public class CateRouteBO : DB_SAPDataContext
{
    public CateRouteBO()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public int CateRouteInsert(ZD_CATE_ROUTE objRoute)
    {
        try
        {
            return ZD_PRC_ZD_CATE_ROUTE_INSERT(objRoute.ROUTENAME, objRoute.LEADTIME, objRoute.ACTIVE);

        }
        catch
        {
            return -1;
        }
    }

    public bool CateRouteUpdate(ZD_CATE_ROUTE objRoute)
    {
        try
        {
            int result = ZD_PRC_ZD_CATE_ROUTE_UPDATE(objRoute.ROUTEID, objRoute.ROUTENAME,objRoute.LEADTIME, objRoute.ACTIVE);
            if (result == 1)
                return true;
            else
                return false;
        }
        catch
        {
            return false;
        }
    }

    public List<ZD_PRC_ZD_CATE_ROUTE_SEARCHResult> CateRouteSearch(ZD_CATE_ROUTE objRoute)
    {
        try
        {
            List<ZD_PRC_ZD_CATE_ROUTE_SEARCHResult> result = new List<ZD_PRC_ZD_CATE_ROUTE_SEARCHResult>();
            result = ZD_PRC_ZD_CATE_ROUTE_SEARCH(objRoute.ROUTENAME, objRoute.LEADTIME, objRoute.ACTIVE).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_CATE_ROUTE_GETALLResult> CateRouteGetAll()
    {
        try
        {
            List<ZD_PRC_ZD_CATE_ROUTE_GETALLResult> result = new List<ZD_PRC_ZD_CATE_ROUTE_GETALLResult>();
            result = ZD_PRC_ZD_CATE_ROUTE_GETALL().ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public List<ZD_PRC_V_ZD_GET_LIST_PROVINCE_GETBYIDResult> TinhThanhGet(string VungID)
    {
        try
        {
            List<ZD_PRC_V_ZD_GET_LIST_PROVINCE_GETBYIDResult> result = new List<ZD_PRC_V_ZD_GET_LIST_PROVINCE_GETBYIDResult>();
            result = ZD_PRC_V_ZD_GET_LIST_PROVINCE_GETBYID(VungID).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public List<ZD_PRC_V_ZD_GET_LIST_DISTRICT_GETBY_TINHTHANHIDResult> QuanHuyenGet(string TinhThanhID)
    {
        try
        {
            List<ZD_PRC_V_ZD_GET_LIST_DISTRICT_GETBY_TINHTHANHIDResult> result = new List<ZD_PRC_V_ZD_GET_LIST_DISTRICT_GETBY_TINHTHANHIDResult>();
            result = ZD_PRC_V_ZD_GET_LIST_DISTRICT_GETBY_TINHTHANHID(TinhThanhID).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_REGION_GETBYIDResult> VungGet(string VungID)
    {
        try
        {
            List<ZD_PRC_ZD_REGION_GETBYIDResult> result = new List<ZD_PRC_ZD_REGION_GETBYIDResult>();
            result = ZD_PRC_ZD_REGION_GETBYID(VungID).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_V_ZD_GET_LIST_WAREHOUSE_GETBYIDResult> KhoGet(string KhoID)
    {
        try
        {
            List<ZD_PRC_V_ZD_GET_LIST_WAREHOUSE_GETBYIDResult> result = new List<ZD_PRC_V_ZD_GET_LIST_WAREHOUSE_GETBYIDResult>();
            result = ZD_PRC_V_ZD_GET_LIST_WAREHOUSE_GETBYID(KhoID).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }

    public int CateRoute_Belong_Insert(ZD_CATE_ROUTE_BELONG objRouteBeLong, string DSTINHTHANHID, string DSQUANHUYENID)
    {
        try
        {
            return ZD_PRC_ZD_CATE_ROUTE_BELONG_INSERT(objRouteBeLong.ROUTEID, objRouteBeLong.KHOID, objRouteBeLong.VUNGID, DSTINHTHANHID, DSQUANHUYENID);

        }
        catch
        {
            return -1;
        }
    }

    public bool CateRoute_Belong_Update(ZD_CATE_ROUTE_BELONG objRouteBeLong)
    {
        try
        {
            int result = ZD_PRC_ZD_CATE_ROUTE_BELONG_UPDATE(objRouteBeLong.ID,objRouteBeLong.ROUTEID, objRouteBeLong.KHOID,objRouteBeLong.VUNGID,objRouteBeLong.TINHTHANHID,objRouteBeLong.QUANHUYENID);
            if (result == 1)
                return true;
            else
                return false;
        }
        catch
        {
            return false;
        }
    }

    public List<ZD_PRC_ZD_CATE_ROUTE_BELONG_SEARCHResult> CateRoute_Belong_Search(ZD_CATE_ROUTE_BELONG objRouteBeLong, string DSTINHTHANHID, string DSQUANHUYENID)
    {
        try
        {
            List<ZD_PRC_ZD_CATE_ROUTE_BELONG_SEARCHResult> result = new List<ZD_PRC_ZD_CATE_ROUTE_BELONG_SEARCHResult>();
            result = ZD_PRC_ZD_CATE_ROUTE_BELONG_SEARCH(objRouteBeLong.ROUTEID, objRouteBeLong.KHOID, objRouteBeLong.VUNGID, DSTINHTHANHID, DSQUANHUYENID).ToList();
            return result;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public List<ZD_PRC_ZD_CATE_BUOI_GETBYIDResult> BuoiGet(int buoiId)
    {
        try
        {
            return ZD_PRC_ZD_CATE_BUOI_GETBYID(buoiId).ToList();
           
        }
        catch (Exception ex)
        {
            return null;
        }
    }
    public ZD_PRC_ZD_CATE_BUOI_GETBYIDResult BuoiGet_SingleLine(int buoiId)
    {
        try
        {
            return ZD_PRC_ZD_CATE_BUOI_GETBYID(buoiId).SingleOrDefault();

        }
        catch (Exception ex)
        {
            return null;
        }
    }

}